//
//  CountryNumberCell.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/27.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit
protocol CountryNumberDelegate: class {
    func selectCountry()
}
class CountryNumberCell: CommonTableViewCell {
    weak var detailDelegate: CountryNumberDelegate?
    lazy var countryBtn: CustomBtn = {
        let btn  = CustomBtn(style: placeStyle.styleRight)
        btn.nameLabel.text = "+86"
        btn.nameLabel.font = UIFont.systemFont(ofSize: 15)
        btn.addTarget(self, action: #selector(selectCountry), for: UIControlEvents.touchUpInside)
        btn.photoImageView.image = UIImage(named: "china")
        return btn
    }()
    

    
    override func setUpUI() {
        super.setUpUI()
        
        self.contentView.addSubview(self.numTextField)
        self.numTextField.snp.makeConstraints { (make) in
            make.left.equalTo(98)
            make.right.equalToSuperview().offset(-15)
            make.top.bottom.equalToSuperview()
        }
        
        let line = UIView()
        line.themeBackground = ThemeManager.ThemeColorKeys.tabLineColor
        self.contentView.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(93)
            make.centerY.equalToSuperview()
            make.width.equalTo(1)
            make.height.equalTo(12)
        }
        
        self.contentView.addSubview(countryBtn)
        countryBtn.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
            make.width.equalTo(93)
        }
        countryBtn.position?.exchangePlace(btn: countryBtn)
    }
    
    override func setIteam(_ item: CYTableviewItem) {
        self.numTextField.placeholder = item.placeHolder
        self.numTextField.setPlaceholderColor()
    }
    
    @objc func selectCountry(model: CountryModel) {
        if self.detailDelegate != nil {
        self.detailDelegate?.selectCountry()
        }
    }
    

    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
